﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Accounting_MembershipFeesReceipt : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string sql = @"
            SELECT  [Mem_FeesID]
      ,[Amount]
      ,[PaidFor]
      ,[RefferenceNo]
      ,[PaidDate]
      ,Name
      ,MemberShipNo
      ,Comn_OfficeName
  FROM [IEB].[dbo].[Mem_Fees] as Fee
  inner join [IEB].[dbo].[Mem_Member] as Mem on Mem.Mem_MemberID = Fee.Mem_MemberID
  inner join [IEB].[dbo].Comn_Office as Office on Mem.Comn_OfficeID = Office.Comn_OfficeID
  where [Mem_FeesID]=" + Request.QueryString["Mem_FeesID"] + @"

SELECT [ACC_JournalDetailID]
      ,[JournalMasterID]
      ,[ACC_ChartOfAccountLabel4ID]
      ,[ACC_ChartOfAccountLabel3ID]
      ,[WorkStation]
      ,[Debit]
      ,[Credit]
      ,[ExtraField3]
      ,[ExtraField2]
      ,[ExtraField1]
      ,[AddedBy]
      ,[AddedDate]
      ,[UpdatedBy]
      ,[UpdatedDate]
      ,[RowStatusID]
  FROM [ERP].[dbo].[ACC_JournalDetail]
  where [Debit]=0 and [JournalMasterID]=(select CAST(RefferenceNo as int)  FROM [IEB].[dbo].[Mem_Fees] where [Mem_FeesID]=" + Request.QueryString["Mem_FeesID"] + @")
            ";

            DataSet ds = DatabaseManager.ExecSQL(sql);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblCentre.Text = ds.Tables[0].Rows[0]["Comn_OfficeName"].ToString();
                lblName.Text = ds.Tables[0].Rows[0]["Name"].ToString();
                lblMembershipNo.Text = ds.Tables[0].Rows[0]["MemberShipNo"].ToString();
                lblDate.Text = DateTime.Parse(ds.Tables[0].Rows[0]["PaidDate"].ToString()).ToString("dd-MM-yyyy");
                lblFeesID.Text = ds.Tables[0].Rows[0]["Mem_FeesID"].ToString();
                lblTotal.Text = ds.Tables[0].Rows[0]["Amount"].ToString();
                lblTkInwords.Text = CommonManager.NumberToWords(int.Parse(ds.Tables[0].Rows[0]["Amount"].ToString().Split('.')[0]));
            }

            if (ds.Tables[1].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[1].Rows)
	                {
		 
                        string l4ID=dr["ACC_ChartOfAccountLabel3ID"].ToString();
                        switch (l4ID)
                        {
                            case "278"://Annual Subscription (Arrear)
                                break;
                            case "279"://Annual Subscription (Advance)
                                break;
                            case "280"://Annual Subscription (Current)
                                txtAnnualSubscription_Current.Text= decimal.Parse(dr["Credit"].ToString()).ToString("0.00");
                                txtAnnualSubscription_Current_ExtraField3.Text = dr["ExtraField3"].ToString();
                                break;
                            case "281"://Composition fee for Life Fellowship
                                break;
                            case "282"://Entrance Fee
                                break;
                            case "283"://Diploma Fee
                                break;
                            case "285"://Re-Enrollment Fee
                                break;
                            case "284"://Equvalance Fee
                                break;
                            case "286"://ID Card Fee
                                txtIDCardFee.Text= decimal.Parse(dr["Credit"].ToString()).ToString("0.00");
                                break;
                            default:
                                break;
                        }
                    }
                
            }
        }


    }
}